import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const Store = new Vuex.Store({
	state: {
		userInfo: {}, //用户信息 
		loginStatus: 0, //登录状态,
		checkedMember:{},//团队报名时勾选的选手列表  以project_id和group_id标记
		teamInfo:{},//团队信息
		appId:'',//appid
	},
	getters: {
		login_Status(state) {
			return state.loginStatus
		},
		user_Info(state) {
			return state.userInfo;
		},
		checked_member(state){
			return state.checkedMember
		},
		team_info(state){
			return state.teamInfo
		},
		appId(state){
			return state.appId
		},
	},
	mutations: {
		setLoginStatus(state, options) {
			state.loginStatus = options
		},
		setUserInfo(state, options) {
			state.userInfo = options
		},
		setCheckedMember(state, options) {
			state.checkedMember = options
		},
		setTeamInfo(state,options){
			state.teamInfo = options
		},
		setAppId(state, options) {
			state.appId = options
		},
	},
	actions: {
		setUserInfo(context, options) {
			context.commit('setUserInfo')
		}
	},
	plugins: [
		createPersistedState({
			storage: {
				getItem: key => wx.getStorageSync(key),
				setItem: (key, value) => wx.setStorageSync(key, value),
				removeItem: key => {}
			}
		})
	]
})

/*
let _store = new Vuex.Store(Store)
export default _store*/

export default Store
